package com.ruoyi.slope.data.weather.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.slope.data.weather.mapper.SlopeWeatherDataMapper;
import com.ruoyi.slope.data.weather.domain.SlopeWeatherData;
import com.ruoyi.slope.data.weather.service.ISlopeWeatherDataService;

/**
 * 气象监测数据Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-02
 */
@Service
public class SlopeWeatherDataServiceImpl implements ISlopeWeatherDataService 
{
    @Autowired
    private SlopeWeatherDataMapper slopeWeatherDataMapper;

    public void scanned(){
        slopeWeatherDataMapper.scanned();
    }

    /**
     * 获取最新降雨量数据
     */
    @Override
    public SlopeWeatherData getLatestRainfall(String deviceSn) {
        return slopeWeatherDataMapper.selectLatestRainfall(deviceSn);
    }

    /**
     * 获取最新气温数据
     */
    @Override
    public SlopeWeatherData getLatestTemperature(String deviceSn) {
        return slopeWeatherDataMapper.selectLatestTemperature(deviceSn);
    }

    public List<SlopeWeatherData> warningSelectSlopeWeatherDataList(SlopeWeatherData slopeWeatherData)
    {
        return slopeWeatherDataMapper.warningSelectSlopeWeatherDataList(slopeWeatherData);
    }


    /**
     * 查询气象监测数据
     * 
     * @param id 气象监测数据主键
     * @return 气象监测数据
     */
    @Override
    public SlopeWeatherData selectSlopeWeatherDataById(Long id)
    {
        return slopeWeatherDataMapper.selectSlopeWeatherDataById(id);
    }

    /**
     * 查询气象监测数据列表
     * 
     * @param slopeWeatherData 气象监测数据
     * @return 气象监测数据
     */
    @DataScope(deptAlias = "s")
    @Override
    public List<SlopeWeatherData> selectSlopeWeatherDataList(SlopeWeatherData slopeWeatherData)
    {
        return slopeWeatherDataMapper.selectSlopeWeatherDataList(slopeWeatherData);
    }

    /**
     * 新增气象监测数据
     * 
     * @param slopeWeatherData 气象监测数据
     * @return 结果
     */
    @Override
    public int insertSlopeWeatherData(SlopeWeatherData slopeWeatherData)
    {
        slopeWeatherData.setCreateTime(DateUtils.getNowDate());
        return slopeWeatherDataMapper.insertSlopeWeatherData(slopeWeatherData);
    }

    /**
     * 修改气象监测数据
     * 
     * @param slopeWeatherData 气象监测数据
     * @return 结果
     */
    @Override
    public int updateSlopeWeatherData(SlopeWeatherData slopeWeatherData)
    {
        return slopeWeatherDataMapper.updateSlopeWeatherData(slopeWeatherData);
    }

    /**
     * 批量删除气象监测数据
     * 
     * @param ids 需要删除的气象监测数据主键
     * @return 结果
     */
    @Override
    public int deleteSlopeWeatherDataByIds(Long[] ids)
    {
        return slopeWeatherDataMapper.deleteSlopeWeatherDataByIds(ids);
    }

    /**
     * 删除气象监测数据信息
     * 
     * @param id 气象监测数据主键
     * @return 结果
     */
    @Override
    public int deleteSlopeWeatherDataById(Long id)
    {
        return slopeWeatherDataMapper.deleteSlopeWeatherDataById(id);
    }
}
